<?php

require_once 'Ext/User/Action/Edit/Email/Interface.php';

class Ext_User_Action_Edit_Email_Adapter_Db extends Ext_User_Action_Edit_Email_Abstract
{
    public function editEmail($email)
    {
        $_appModelDbTableUserAccountBaseEmail = App_Model_DbTable_User_Account_Base_Email::getInstance();
        $_userAccountBaseEmailRow = $_appModelDbTableUserAccountBaseEmail->getRowByUserId($this->_userId);
        if(!$_userAccountBaseEmailRow)
    	{
    	    $_result = $this->setResult(Ext_User_Action_Edit_Email_Result::FAILURE_RECORD_NOT_FONUD);
            return $_result;
    	}
    	
    	$row = array(
            'email' => $email,
        );
        $_appModelDbTableUserAccountBaseEmail->addOld($row, $this->_userId);

        $_result = $this->setResult(Ext_User_Action_Edit_Email_Result::SUCCESS);
        return $_result;

    }

}
